package hu.mapro.jam.commons;

import java.io.BufferedReader;
import java.io.IOException;

import com.google.common.base.Throwables;

public class Input {
	
	final public BufferedReader in;
	
	public Input(BufferedReader in) {
		super();
		this.in = in;
	}

	public int[] integers() {
		try {
			String[] strings = in.readLine().split(" ");
			
			int[] ints = new int[strings.length];
			
			for (int i=0 ; i<ints.length ; i++) {
				ints[i] = Integer.parseInt(strings[i]);
			}
			
			return ints;
		} catch (Exception e) {
			throw Throwables.propagate(e);
		}
	}

	public double[] doubles() {
		try {
			String[] strings = in.readLine().split(" ");
			
			double[] doubles = new double[strings.length];
			
			for (int i=0 ; i<doubles.length ; i++) {
				doubles[i] = Double.parseDouble(strings[i]);
			}
			
			return doubles;
		} catch (Exception e) {
			throw Throwables.propagate(e);
		}
	}
	
	public String readLine() {
		try {
			return in.readLine();
		} catch (IOException e) {
			throw Throwables.propagate(e);
		}
	}
	
}
